import cv2
import dgh
import numpy as np

def extract_minutiae(image_path):
    # 使用OpenCV读取指纹图像
    fingerprint_image = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
    # 返回提取的指纹特征
    return dgh.calculate_dgh(fingerprint_image)

def fingerprint_matching(image1_path, image2_path):
    # 提取两个指纹图像的特征
    features1 = extract_minutiae(image1_path)
    features2 = extract_minutiae(image2_path)
    
    # 计算相似性度量,计算欧氏距离
    similarity_score =  np.linalg.norm(np.array(features1) - np.array(features2))
    
    # 返回相似性度量结果
    return similarity_score

# 示例用法
image1_path = "tmp/fingerprint_image.bmp"
image2_path = "data/a567.bmp"
similarity = fingerprint_matching(image1_path, image2_path)
print("指纹相似性度量：", similarity)
